<template>
	<view style="height: 100%;overflow: hidden;">
		<u-navbar style="position: fixed;" border-bottom="false"  background="rgba(0,0,0,0)" is-fixed="true" z-index="999" title=" "></u-navbar>
		<image src="https://love-space.oss-cn-chengdu.aliyuncs.com/uploads/20220907/e6d25f7ddd3477af4a7f2142d5e1045e.jpg"  style="width: 100%;height: 100%;"></image>
		<view @click="selectTime(1)" style="position: fixed;z-index: 1;width: 80%;background: #fff;border-radius: 30px;bottom: 120px;left: 10%;color: #fa1e8a;text-align: center;line-height: 36px;">
			{{time1}}
		</view>
		<view @click="selectTime(2)"  style="position: fixed;z-index: 1;width: 80%;background: #fff;border-radius: 30px;bottom: 70px;left: 10%;color: #fa1e8a;text-align: center;line-height: 36px;">
			{{time2}}
		</view>
		<view @click="baogao" style="position: fixed;z-index: 1;width: 80%;border-radius: 30px;bottom: 20px;left: 10%;text-align: center;line-height: 36px;" class="button cfff">
			开始计算
		</view>
		<u-picker default-time="1995-01-01" @confirm="confirms" start-year="1980" mode="time" v-model="show" :params="params"></u-picker>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				params: {
					year: true,
					month: true,
					day: true,
					hour: false,
					minute: false,
					second: false
				},
				show: false,
				time1:'请选择',
				time2:'请选择',
				type:''
			}
		},
		onLoad() {
			uni.setNavigationBarColor({
			    frontColor: '#000000',  
			    backgroundColor: '#ffffff',    
			})
		},
		methods: {
			selectTime(e){
				this.show=true
				this.type=e
			},
			confirms(e){
				console.log(e)
				let data={
					y1:'',
					y2:''
				}
				if(this.type==1){
					this.time1=e.year+'-'+e.month+'-'+e.day
					data.y1=e.year
				}else{
					this.time2=e.year+'-'+e.month+'-'+e.day
					data.y2=e.year
				}
				
			},
			baogao(e){
				if(this.time1=='请选择'||this.time2=='请选择'){
					return uni.showToast({
						title:'请选择日期',
						icon:'none'
					})
				}
				let data={
					y1:this.time1,
					y2:this.time2
				}
				this.$u.vuex('vuex_time',data)
				uni.navigateTo({
					url:'./detail?type=0'
				})
			}
		}
	}
</script>

<style>
page{
	height: 100%;
}
</style>
